import type { ProxyOptions } from 'vite'

interface proxyType {
  dev: Record<string, string | ProxyOptions>
  test: Record<string, string | ProxyOptions>
  pre: Record<string, string | ProxyOptions>
}

const Proxys: proxyType = {
  dev: {
    '/api': {
      // target: 'http://10.108.10.165/api',
      target: 'http://light.saas.sit.guoxintianyu.com/api',
      changeOrigin: true,
      rewrite: (path) => path.replace(/^\/api/, '')
    },
    '/websocket': {
      target: 'ws://light.saas.sit.guoxintianyu.com/websocket',
      changeOrigin: true,
      ws: true,
      rewrite: (path) => path.replace(/^\/websocket/, '')
    }
  },
  test: {
    '/api': {
      target: 'http://light.saas.uat.guoxintianyu.com/api',
      changeOrigin: true,
      rewrite: (path) => path.replace(/^\/api/, '')
    },
    '/websocket': {
      target: 'ws://light.saas.uat.guoxintianyu.com/websocket',
      changeOrigin: true,
      ws: true,
      rewrite: (path) => path.replace(/^\/websocket/, '')
    }
  },
  pre: {
    '/api': {
      target: 'http://localhost/pre',
      changeOrigin: true,
      rewrite: (path) => path.replace(/^\/api/, '')
    },
    '/websocket': {
      target: 'http://localhost/pre',
      changeOrigin: true,
      rewrite: (path) => path.replace(/^\/websocket/, '')
    }
  }
}

export default Proxys
